package com.loveto.service;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

public class ExplainTournamentActivity extends Activity implements
View.OnClickListener {
	
	// 사용하는 변수들
	private LinearLayout v_area_step01;
	private LinearLayout v_area_step02;
	private LinearLayout v_area_step03;
	private ImageView v_btn_step01;
	private ImageView v_btn_step02;
	private ImageView v_btn_step03;
	private ScrollView v_scrollView;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.loveto_explain_tournament);
		
		//변수 초기화
		v_area_step01 = (LinearLayout)findViewById(R.id.area_step01);
		v_area_step02 = (LinearLayout)findViewById(R.id.area_step02);
		v_area_step03 = (LinearLayout)findViewById(R.id.area_step03);
		v_btn_step01 = (ImageView)findViewById(R.id.btn_step01); 
		v_btn_step02 = (ImageView)findViewById(R.id.btn_step02); 
		v_btn_step03 = (ImageView)findViewById(R.id.btn_step03);
		v_scrollView = (ScrollView)findViewById(R.id.scrollView);
		
		//클릭 리스너 달기
		((RelativeLayout)findViewById(R.id.btn_goto_back)).setOnClickListener(this);
		v_btn_step01.setOnClickListener(this);
		v_btn_step02.setOnClickListener(this);
		v_btn_step03.setOnClickListener(this);
		((TextView)findViewById(R.id.gotoStep01)).setOnClickListener(this);
		((TextView)findViewById(R.id.gotoStep02)).setOnClickListener(this);
		((TextView)findViewById(R.id.gotoStep03)).setOnClickListener(this);
		((TextView)findViewById(R.id.gotoStep02_2)).setOnClickListener(this);
		
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
			case R.id.btn_step01:
				setUnvisible();
				v_area_step01.setVisibility(LinearLayout.VISIBLE);
				v_btn_step01.setImageResource(R.drawable.btn_explain_step01_selected);
				break;
			case R.id.gotoStep01:
				setUnvisible();
				v_area_step01.setVisibility(LinearLayout.VISIBLE);
				v_btn_step01.setImageResource(R.drawable.btn_explain_step01_selected);
				break;
			case R.id.btn_step02:
				setUnvisible();
				v_area_step02.setVisibility(LinearLayout.VISIBLE);
				v_btn_step02.setImageResource(R.drawable.btn_explain_step02_selected);
				break;
			case R.id.gotoStep02:
				setUnvisible();
				v_area_step02.setVisibility(LinearLayout.VISIBLE);
				v_btn_step02.setImageResource(R.drawable.btn_explain_step02_selected);
				break;
			case R.id.gotoStep02_2:
				setUnvisible();
				v_area_step02.setVisibility(LinearLayout.VISIBLE);
				v_btn_step02.setImageResource(R.drawable.btn_explain_step02_selected);
				break;
			case R.id.btn_step03:
				setUnvisible();
				v_area_step03.setVisibility(LinearLayout.VISIBLE);
				v_btn_step03.setImageResource(R.drawable.btn_explain_step03_selected);
				break;
			case R.id.gotoStep03:
				setUnvisible();
				v_area_step03.setVisibility(LinearLayout.VISIBLE);
				v_btn_step03.setImageResource(R.drawable.btn_explain_step03_selected);
				break;
			case R.id.btn_goto_back:
				finish();
				break;
		}
	}
	
	private void setUnvisible() {
		v_scrollView.scrollTo(0, 0);
		v_area_step01.setVisibility(LinearLayout.GONE);
		v_area_step02.setVisibility(LinearLayout.GONE);
		v_area_step03.setVisibility(LinearLayout.GONE);
		v_btn_step01.setImageResource(R.drawable.btn_explain_step01_unselected);
		v_btn_step02.setImageResource(R.drawable.btn_explain_step02_unselected);
		v_btn_step03.setImageResource(R.drawable.btn_explain_step03_unselected);
	}
}
